﻿using System;

namespace Basmus.ReadWrite
{
    public class BooleanReaderWriter : IReaderWriter<bool>
    {
        public ReadResult<bool> Read(string str)
        {
            Boolean value;
            if (Boolean.TryParse(str, out value))
            {
                return ReadResult<Boolean>.Success(value);
            }
            return ReadResult<Boolean>.Error();
        }

        public string Write(bool value)
        {
            return value.ToString();
        }
    }
}